package com.briup.cms;

import java.util.ArrayList;
import java.util.Arrays;

public class test3 {
    public static void main(String[] args) {
        String str = "&&ab&&2&&3";
        String split = "&&";
        int length = split.length();
        int count =0;
        ArrayList<Object> list = new ArrayList<>();
        char[] array = str.toCharArray();
        for (int i = 0; i < array.length -length+1; i++) {
            String s="";
            for (int j = 0; j <length; j++) {
                 s = s+array[i+j];
            }
            if(s.equals(split)){
                if(i==0) {
                    count=length;
                    continue;
                }
                list.add(getString(count,i,array));
                count=i+length;
            }
        }
        list.add(getString(count,array.length,array));
        System.out.println(Arrays.toString(list.toArray(new String[0])));


    }
    public static String getString(int count,int length,char[] array){
        StringBuilder builder = new StringBuilder();
        for (int j = count; j < length; j++) {
            builder.append(array[j]);
        }
        return builder.toString();
    }

}
